package com.yesep.learn.design.structural.decorator;

import com.yesep.learn.design.common.*;
import com.yesep.learn.design.common.util.*;

/**
 * 播放器装饰器
 */
public abstract class MediaPlayerDecorator implements IMediaPlayer {


    private IMediaPlayer player;

    public MediaPlayerDecorator(IMediaPlayer adapter) throws Exception {
        player = adapter;
    }

    public MediaPlayerDecorator(Class<? extends IMediaPlayer> cls) throws Exception {
        player = Util.getInstance(cls);
    }

    public IMediaPlayer getPlayer() {
        return player;
    }

    @Override
    public void play(String fileName) {
        player.play(fileName);
    }

    @Override
    public void pause() {
        player.pause();
    }

    @Override
    public void stop() {
        player.stop();
    }

    @Override
    public String getFileName() {
        return player.getFileName();
    }
}
